#include "block_file.h"

using namespace std;

namespace PFS
{
    const char* Block2File::find_map_file(const uint32_t block_id) const
    {
        ITER it = block_file_map.find(block_id);
        if(it != block_file_map.end())
            return it->second.c_str();
        else
            return NULL;
    }

    void Block2File::add_map_file(const uint32_t block_id, const char* file_name)
    {
        block_file_map[block_id] = file_name;
    }

    void Block2File::remove_map_file(const uint32_t block_id)
    {
        block_file_map.erase(block_id);
    }

    const char* Block2File::rename_map_file(const uint32_t block_id, const char* new_file_name)
    {
        string old_name = block_file_map[block_id];
        block_file_map[block_id] = new_file_name;
        return old_name.c_str();
    }
}
